package com.eshop.web.component;

import com.eshop.domain.Product;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * Created by Sergey on 13.12.13.
 */
public class ProductsListView extends ListView<Product> {
    private static final Logger LOGGER = LoggerFactory.getLogger(ProductsListView.class);

    private String contentElementId;

    public ProductsListView(String id, String contentElementId, IModel<? extends List<? extends Product>> model) {
        super(id, model);
        this.contentElementId = contentElementId;
    }

    @Override
    protected void populateItem(ListItem<Product> productListItem) {
        Product product = (Product) productListItem.getDefaultModelObject();
        productListItem.add(new ProductPanel(contentElementId, product));
    }
}
